package com.tedu.ds.workRecord.controller;

import com.tedu.ds.base.response.JsonResult;
import com.tedu.ds.workRecord.pojo.dto.WorkRecordParam;
import com.tedu.ds.workRecord.pojo.dto.WorkRecordQuery;
import com.tedu.ds.workRecord.service.WorkRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/v1/workRecord")
@Api(tags = "工作记录模块")
public class WorkRecordController {
    @Autowired
    private WorkRecordService workRecordService;

    @PostMapping("/select")
    @ApiOperation("查询功能")
    public JsonResult select(@RequestBody WorkRecordQuery workRecordQuery){
        return JsonResult.ok(workRecordService.select(workRecordQuery));
    }

    @PostMapping("/save")
    @ApiOperation("新增和更新功能")
    public JsonResult save(@RequestBody WorkRecordParam workRecordParam){
        workRecordService.save(workRecordParam);
        return JsonResult.ok();
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation("根据id删除")
    public JsonResult deleteById(@PathVariable Integer id){
        workRecordService.deleteById(id);
        return JsonResult.ok();
    }
}
